feat: Add canonical serialization mode to event and variable serialization#8552
feat: Add canonical serialization mode to event and variable serialization#8552ViktorVovk wants to merge 1 commit into
Conversation
- Introduced a global canonical mode in the Serializer class to ensure consistent JSON output. - Updated various event serialization methods to include default values and alphabetical key ordering when canonical mode is enabled. - Added support for canonical serialization in the Variable class. - Enhanced the SerializerElement to handle canonical mode during JSON conversion. - Updated related tests and preferences to accommodate the new serialization behavior.
Shouldn't this make things harder to review for a human (or even an AI) because there is less noise?
Agree it's not great and probably something we can fix! |
|
Good day, and thank you for the preliminary review. I’ll try to answer your question. The idea is that when the This way, when a value changes, only the value itself changes, making the diff much clearer — you can simply see that a property changed from With the default behavior, when a value is |
Add
canonicalEventSerializationpreference for stable, diff-friendly event JSONProblem
GDevelop's event serialization omits properties that hold default values —
disabled,folded,inverted,awaitare only written to JSON whentrue;events,variables,subInstructions,loopIndexVariable, etc. are only written when non-empty. This causes two kinds of noise in git diffs:Both issues make per-event diffs hard to review in version-controlled projects.
Solution
Add a project-level preference
canonicalEventSerialization(opt-in, defaultfalse). When enabled:false,"",[]), so toggling a flag produces a single-line value change, not an insertion/deletion.The preference is controlled via
gdevelop-settings.yaml(already read by the IDE on project open):